For the truss structures shown below create a MATLAB program

For the truss structures shown below, create a MATLAB program that will determine the internal forces in the structural members. Print out the reactions, the members’ internal forces, and a check on the solution

The Full commented answer (in well commented Matlbad codes) please...

\"9
9 kN 15 12 m 17 12 20 2 kN 4 kN 6 kN 4 kN 2 kN 6 bays at 9 m each

Solution

% The below program is started by typing truss(\'input_data_file.txt\') at the MATLAB prompt.Any file name can be used.

function truss(file_name);
% OPEN DATA FILE
fid = fopen(file_name, \'r\');
% READ DATA - READ NODE DATA - First read the number of nodes in the
truss
Number_nodes=fscanf(fid, \'%d\', 1);
% Read the coordinates for each node
for i=1:Number_nodes
Node=fscanf(fid, \'%d\', 1);
Coordinate(Node, 1)=fscanf(fid, \'%g\', 1);
Coordinate(Node, 2)=fscanf(fid, \'%g\', 1);
end

% READ DATA - READ ELEMENT DATA - Now read the number of elements and
the
% element definition
Number_elements=fscanf(fid, \'%d\', 1);
M=zeros(2*Number_nodes, 2*Number_nodes);
Chapter 2 - Static Truss Problem Page 11 of 14
for i=1:Number_elements
Element=fscanf(fid, \'%d\', 1);
Node_from=fscanf(fid, \'%d\', 1);
Node_to=fscanf(fid, \'%d\', 1);

dx=Coordinate(Node_to,1)-Coordinate(Node_from,1);
dy=Coordinate(Node_to,2)-Coordinate(Node_from,2);
Length=sqrt(dx^2 + dy^2);

M(2*Node_from-1,Element) = dx/Length;
M(2*Node_to-1, Element) = -dx/Length;
M(2*Node_from, Element) = dy/Length;
M(2*Node_to, Element) = -dy/Length;
end

% READ DATA - READ REACTION DATA - Now read in the reactions
Number_reactions = fscanf(fid, \'%d\', 1);
if (2*Number_nodes ~= (Number_elements + Number_reactions))
error(\'Invalid number of nodes, elements, and reactions\');
end

for i=1:Number_reactions;
Reaction = fscanf(fid, \'%d\', 1);
Node=fscanf(fid, \'%d\', 1);
Direction = fscanf(fid, \'%s\', 1);
if ((Direction == \'y\') || (Direction == \'Y\'))
M(2*Node, Number_elements+Reaction)=M(2*Node,
Number_elements+Reaction)+1;
elseif ((Direction == \'x\')||(Direction == \'X\'))
M(2*Node-1, Number_elements+Reaction)=M(2*Node-1,
Number_elements+Reaction)+1;
else
error(\'Invalid direction for reaction\')
end
end

% READ DATA - READ EXTERNAL FORCE DATA - Now read in the external
forces
External=zeros(2*Number_nodes,1);
Number_forces=fscanf(fid, \'%d\', 1);
for i=1:Number_forces
Node =fscanf(fid, \'%d\', 1);
Force=fscanf(fid, \'%g\', 1);
Direction = fscanf(fid, \'%g\', 1);
External(2*Node-1)=External(2*Node-1)-Force*cos(Direction*(pi/180));
External(2*Node) =External(2*Node) -Force*sin(Direction*(pi/180));
end

External
% COMPUTE FORCES - Solve the system of equations
Chapter 2 - Static Truss Problem Page 12 of 14
A=M\\External;
% REPORT FORCES - FORCES IN THE ELEMENTS
for i = 1:Number_elements
fprintf(\'Element %d = %g \ \', i, A(i))
end
% REPORT FORCES - REACTION FORCES
for i = 1:Number_reactions
fprintf(\'Reaction %d = %g \ \', i, A(Number_elements + i))
end
end

For the truss structures shown below, create a MATLAB program that will determine the internal forces in the structural members. Print out the reactions, the me
For the truss structures shown below, create a MATLAB program that will determine the internal forces in the structural members. Print out the reactions, the me

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site